package com.sysu.ooad.dao.impl;

import java.util.List;

import org.springframework.stereotype.Component;

import com.sysu.ooad.dao.CommonDao;
import com.sysu.ooad.dao.CourseDao;
import com.sysu.ooad.entity.Course;
import com.sysu.ooad.entity.Student;

@Component("courseDao")
public class CourseDaoImpl extends CommonDao implements CourseDao {
	
	@SuppressWarnings("unchecked")
	public List<Student> findStudents(Course c) {
		List<Student> students = (List<Student>) hibernateTemplate.find("from Student s where s.course = ?", new Object[]{c});
		return students;
	}

	public void update(Course c) {
		hibernateTemplate.update(c);
	}

	public Course findById(Integer id) {
		return (Course)hibernateTemplate.get(Course.class, id);
	}
	
}
